"use strict";
cc._RF.push(module, '95277heKZNNnrmUqly4CRMS', 'Logger');
// script/Core/Libs/Logger.ts

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Config_1 = require("../../Config/Config");
var log = cc.log;
/**
 * 日志管理
 */
var Logger = /** @class */ (function () {
    function Logger() {
    }
    //打印范围内时间消耗
    //记录开始计时
    Logger.start = function (describe) {
        if (describe === void 0) { describe = "Time"; }
        console.time(describe);
    };
    Logger.end = function (describe) {
        if (describe === void 0) { describe = "Time"; }
        console.timeEnd(describe);
    };
    //打印表格
    Logger.table = function (msg) {
        if (!Config_1.GameParams.Debug) {
            return;
        }
        console.table(msg);
    };
    /**
     * 打印标准日志
     * @param msg       日志消息
     */
    Logger.trace = function (msg, color) {
        if (color === void 0) { color = "color:#000000;"; }
        // 标记没有打开，不打印该日志
        if (!Config_1.GameParams.Debug) {
            return;
        }
        var backLog = console.log || log;
        backLog.call(null, "%c%s%s", color, this.getDateString(), msg);
    };
    /**
     * 输出日志
     * @param tag       日志类型
     * @param msg       日志内容
     * @param color     日志文本颜色
     * @param describe  日志标题描述
     */
    Logger.print = function (msg, color) {
        if (color === void 0) { color = "color:#000000;"; }
        // 标记没有打开，不打印该日志
        if (!Config_1.GameParams.Debug) {
            return;
        }
        var backLog = console.log || log;
        backLog.call(null, "%c%s%s%s:%o", color, this.getDateString(), this.stack(5), msg);
    };
    Logger.stack = function (index) {
        var e = new Error();
        var lines = e.stack.split("\n");
        var result = [];
        lines.forEach(function (line) {
            var _a;
            line = line.substring(7);
            var lineBreak = line.split(" ");
            if (lineBreak.length < 2) {
                result.push(lineBreak[0]);
            }
            else {
                result.push((_a = {}, _a[lineBreak[0]] = lineBreak[1], _a));
            }
        });
        var list = [];
        var splitList = [];
        if (index < result.length - 1) {
            var value;
            for (var a in result[index]) {
                var splitList = a.split(".");
                if (splitList.length == 2) {
                    list = splitList.concat();
                }
                else {
                    value = result[index][a];
                    var start = value.lastIndexOf("/");
                    var end = value.lastIndexOf(".");
                    if (start > -1 && end > -1) {
                        var r = value.substring(start + 1, end);
                        list.push(r);
                    }
                    else {
                        list.push(value);
                    }
                }
            }
        }
        if (list.length == 1) {
            return "[" + list[0] + ".ts]";
        }
        else if (list.length == 2) {
            return "[" + list[0] + ".ts->" + list[1] + "]";
        }
        return "";
    };
    Logger.getDateString = function () {
        var d = new Date();
        var str = d.getHours().toString();
        var timeStr = "";
        timeStr += (str.length == 1 ? "0" + str : str) + ":";
        str = d.getMinutes().toString();
        timeStr += (str.length == 1 ? "0" + str : str) + ":";
        str = d.getSeconds().toString();
        timeStr += (str.length == 1 ? "0" + str : str) + ":";
        str = d.getMilliseconds().toString();
        if (str.length == 1)
            str = "00" + str;
        if (str.length == 2)
            str = "0" + str;
        timeStr += str;
        timeStr = "[" + timeStr + "]";
        return timeStr;
    };
    return Logger;
}());
exports.default = Logger;

cc._RF.pop();